import request from '../utils/request'
export function getBanner () {
  return request({
    url: '/api/banner',
    method: 'get'
  })
}

// 获取文章列表分类
export function getBlogType () {
  return request({
    url: '/api/blogtype',
    method: 'get'
  })
}

/**
 * 获取博客数量{page:当前页码，limit:页容量，categoryId：所属分类}
 * @param {Object} params{ page = 1,limit = 10, categoryId = 1}
 * @returns {AxiosPromise}
 */
export function getBlogs (params) {
  return request({
    url: '/api/blog',
    method: 'get',
    params
  })
}

/**
 *  获取单个博客
 * @param params {{id}}
 * @returns {AxiosPromise}
 */
export function getBlog (params) {
  return request({
    url: `/api/blog/${params.id}`,
    method: 'get'
  })
}

/**
 *  提交评论{昵称，内容，评论的博客id}
 * @param {Object} data{nickname, content, blogId}
 * @returns {AxiosPromise}
 */
export function postComment (data) {
  return request({
    url: '/api/comment',
    method: 'post',
    data
  })
}

/**
 *  提交评论{当前页，容量，评论的博客id}
 * @param {Object} data{page, limit, blogId}
 * @returns {AxiosPromise}
 */
export function getComments (params) {
  return request({
    url: '/api/comment',
    method: 'get',
    params
  })
}

/**
 * 获取全局设置
 * @returns {AxiosPromise}
 */
export function getSetting () {
  return request({
    url: '/api/setting',
    method: 'get'
  })
}

/**
 * 关于我个人简历
 * @returns {AxiosPromise}
 */
export function getAbout () {
  return request({
    url: '/api/about',
    method: 'get'
  })
}

/**
 * 获取项目
 * @returns {Promise<AxiosResponse<any>>}
 */

export function getProjects () {
  return request({
    url: '/api/project',
    method: 'get'
  })
}

/**
 * 获取留言列表{ page = 1, limit = 10 }
 * @returns {Promise<AxiosResponse<any>>}
 */

export function getMessages (params) {
  return request({
    url: '/api/message',
    method: 'get',
    params
  })
}
/**
 * 获取项目 msgInfo
 * @returns {Promise<AxiosResponse<any>>}
 */

export function postMessage (data) {
  return request({
    url: '/api/message',
    method: 'post',
    data
  })
}
